package com.leo.model;

/**
 * @ClassName ArrayQuene2
 * @Description
 * @Author wangss
 * @date 2022.01.30 10:59
 * @Version 1.0
 */
public class ArrayQuene2 {

    private String items[];

    private int n;

    private int head = 0;

    private int tail = 0;

    public ArrayQuene2(int capacity) {
        items = new String[capacity];
        this.n = capacity;
    }

    public boolean push(String itm) {
        if (tail == n) {
            return false;
        }
        items[tail] = itm;
        tail++;
        return true;
    }

    public String poll() {
        if (head == tail) {
            return null;
        }
        String ret = items[head];
        head++;
        return ret;
    }
}
